<template>
  <el-container class="work-warp">
    <div class="top">
      <FormPanel ref="formPanel" :list="orderList" :cols="3" :labelWidth="120" formType="add" :isSubmitBtn="false" @formChange="getOrderList" />
      <el-row>
        <el-button type="primary" :loading="addBtnState" @click="query">查 询</el-button>
        <el-button type="primary" :loading="addBtnState" @click="reset">重 置</el-button>
      </el-row>
    </div>
    <FilterTable
      ref="table"
      :height="200"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      selectionType="single"
      :datakey="'rows'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="arr => (this.onChangeColumn = arr)"
    ></FilterTable>
    <div class="footer">
      <el-button type="primary" :loading="addBtnState" @click="saveDialog">确 定</el-button>
      <el-button @click="closeDialog">取 消</el-button>
    </div>
  </el-container>
</template>
<script>
import { getOrderList } from '@/api/repair/repair/activitesManage/index';
import { dictionary } from '@/utils/dictMixin';
export default {
  name: 'activity',
  components: {},
  mixins: [dictionary],
  props: ['workNo'],
  data() {
    return {
      orderList: this.createFormList(),
      addBtnState: null,
      fetchApi: getOrderList,
      fetchParams: { xhrAbort: true },
      columns: this.createTableColumns(),
      showAddNew: false,
      detaildata: '',
      huoDongSeletRow: [],
      onChangeColumn: []
    };
  },
  computed: {},
  methods: {
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '活动编号',
          fieldName: 'activityCode',
          placeholder: '',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '活动名称',
          fieldName: 'activityName',
          placeholder: '',
          initialValue: ''
        },
        {
          type: 'SELECT',
          label: '发布状态',
          fieldName: 'releaseTag',
          initialValue: 80781002,
          itemList: this.createDictList('8078'),
          disabled: true
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '活动编号',
          dataIndex: 'ACTIVITY_CODE',
          sorter: true
        },
        {
          title: '活动名称',
          dataIndex: 'ACTIVITY_NAME',
          sorter: true
        },
        //  {   //目前先不展示
        //   title: '业务类型',
        //   dataIndex: 'businessType',
        //   sorter: true,
        //     render: props => {
        //     return <span>{this.createDictText(props.row.businessType,'8047')}</span>;
        //   }
        // },
        // {
        //   title: '全球活动编号',
        //   dataIndex: 'GLOBAL_ACTIVITY_CODE',
        //   sorter: true
        // },
        // {
        //   title: '主题',
        //   dataIndex: 'ACTIVITY_TITLE',
        //   sorter: true
        // },
        // {
        //   title: '活动类型',
        //   dataIndex: 'ACTIVITY_TYPE',
        //   sorter: true,
        //   render: props => {
        //     return <span>{this.createDictText(props.row.ACTIVITY_TYPE,'8080')}</span>;
        //   }
        // },
        // {
        //   title: '活动类别',
        //   dataIndex: 'ACTIVITY_KIND',
        //   sorter: true,
        //     render: props => {
        //     return <span>{this.createDictText(props.row.ACTIVITY_KIND, '8079')}</span>;
        //   }
        // },
        {
          title: '开始日期',
          dataIndex: 'BEGIN_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '结束日期',
          dataIndex: 'END_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '发布时间',
          dataIndex: 'RELEASE_DATE',
          sorter: true,
          dateFormat: 'yyyy-MM-dd'
        },
        {
          title: '发布状态',
          dataIndex: 'RELEASE_TAG',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.RELEASE_TAG, '8078')}</span>;
          }
        },
        {
          title: '工时费',
          dataIndex: 'LABOUR_AMOUNT',
          precision: 2,
          sorter: true
        },
        {
          title: '维修材料费',
          dataIndex: 'REPAIR_PART_AMOUNT',
          precision: 2,
          sorter: true
        },
        {
          title: '活动总金额',
          dataIndex: 'ACTIVITY_AMOUNT',
          precision: 2,
          sorter: true
        },
        {
          title: '是否下发',
          dataIndex: 'DOWN_TAG',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.DOWN_TAG, '1004')}</span>;
          }
        },
        {
          title: '是否多次参加活动',
          dataIndex: 'IS_REPEAT_ATTEND',
          sorter: true,
          render: props => {
            return <span>{this.createDictText(props.row.IS_REPEAT_ATTEND, '1004')}</span>;
          }
        }
      ];
    },
    getOrderList(val) {
      this.fetchParams = Object.assign({}, val, { xhrAbort: false });
    },
    query() {
      this.$refs.formPanel.SUBMIT_FORM();
    },
    reset() {
      this.$refs.formPanel.RESET_FORM();
    },
    closeDialog() {
      this.$emit('close1', false);
    },
    saveDialog() {
      if (this.onChangeColumn.length > 0) {
        let obj = this.onChangeColumn[0];
        this.$emit('ReceiveData', obj);
      }
    }
  }
};
</script>
<style lang="less" scoped>
.work-warp {
  flex-direction: column;
  .top {
    width: 100%;
    display: flex;
    flex-direction: column;

    .el-row {
      text-align: center;
    }
  }

  .footer {
    text-align: center;
  }
}
</style>
